<?php
include "includeFiles.php";
include "../../page.php";
//if(empty($_SESSION['user_id'])) echo "<script>location.href='login.php';<//script>";

 function unsetArray($array,$delarr){
		foreach ($array as $bkey=>$bvalue){
			foreach ($delarr as $key=>$value){
				if($value == $bkey){
				unset($array[$bkey]);		
			    }
		     }
	    }
		return $array;
	}


function insert($arr,$table){
    	if($arr){
    		foreach ($arr as $key=>$value){
    			@$fild[]  = "`".$key."`";
    			@$vals[]  = "'".$value."'";
    		}
    	}
    	$fild = implode($fild,",");
    	$vals = implode($vals,",");
    	return @$sql  =" insert into ".$table."(".$fild.")values(".$vals.")";
    }
	
	
	function update($arr,$table,$where){
		$str="UPDATE `$table` SET ";
		foreach ($arr as $key=>$value){
			$str_key.="`".$key."`='".$value."',";
		}
		$str_key=substr($str_key,0,-1);
		foreach ($where as $key=>$value){
			$sql_where.="`$key`"."='".$value."' AND";
		}
		$sql_where=substr($sql_where,0,-4);
		return $sql_update=$str.$str_key." WHERE ".$sql_where.";";
		
	}
	

if($_POST['action'] == 'del'){
	 $strs = implode(',',$_POST['ID']);
	 $sql = "delete  from  `hy_b_3g` WHERE  SpecialCateID in ($strs) ";
     $msg = $objDb->query($sql);
     if($msg) $objBase->popup("删除成功！"); else $objBase->popup("删除失败！"); 
}

?>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<link href="../css/edit.css" rel="stylesheet" type="text/css" />
<table summary="" id="pagehead" cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
    <td width="23%"><h1>3g号码管理</h1></td>
    <td width="77%" class="actions"><table summary="" cellpadding="0" cellspacing="0" border="0" align="right">
        <tr>
          <td class="active"><a href="3g_admin_list.php" class="view">管理列表</a></td>
          <td ><a href="3g_add.php" class="edit">新增</a></td>
        </tr>
      </table></td>
  </tr>
</table>
<script type="text/javascript" src="../../js/jquery-1.4.4.min.js"></script>
<?php
                $sql = "SELECT * FROM `hy_b_3g` WHERE  1  ";
				$result = mysql_query($sql);
				$total = mysql_num_rows($result);
				//调用pageft()，每页显示10条信息（使用默认的20时，可以省略此参数），使用本页URL（默认，所以省略掉）。
				_PAGEFT($total,20);
			    echo "结果总和:".$total;
				$SQL2 = $sql." order by `SpecialCateID` DESC limit $firstcount,$displaypg  ";
				$objDb->query($SQL2);
		        $result = $objDb->get_data();
	        ?>
<form action="#" method="post" name="form1" onsubmit="return abc();">
  <table cellspacing="0" cellpadding="0" width="100%"  class="listtable">
    <tr id='first'>
      <td><input name="action" type="hidden" value="del" >
        <input type="button" value="全选/全不选" id="unSelect"></td>
      <td>编号</td>
      <td>电话号码</td>
      <td>选号费</td>
      <td>号码归属地</td>
      <td>号码状态</td>
      <td> 号码归属品牌</td>
      <td>操作</td>
    </tr>
    <?php
				if(empty($total)) echo "<tr><Td colspan=\"6\"><center>对不起！资料暂时为空！</center></td></tr>";
				if($result){
				 foreach($result as $key=>$value){
				?>
    <tr id="content">
      <td><input name="ID[]"  id="ID[]" type="checkbox" value="<?php echo $value['SpecialCateID'];?>" /></td>
      <td><a href="3g_add.php?id=<?=$value['SpecialCateID']?>"><?php echo $value['tele_code'];?></a></td>
      <td ><?=$value['Serial_number']?>
        </a></td>
        <td>
      <?=$value['Fee_code_fee']?>
      </td>
      <td><?=$value['cityid']?></td>
      <td><span class="word1">空闲/上架</span></td>
      <td><?
			
			 $arr = array(
			      'GSM01'=>'GSM普通世界风',
  			      'GSM02'=>'GSM流量王',
				  'GSM03'=>'GSM惠民卡',
				  'WCDMA01'=>'WCDMA-3G后付费',
				   'WCDMA02'=>'WCDMA-3G预付费',
								  
				  );
				  echo $arr[$value['tele_code']];
			?></td>
      <td><a href="3g_add.php?id=<?=$value['SpecialCateID']?>">编辑?</a>
      </td>
    </tr>
    <?
				  } }
	           
?>
  </table>
  <input type="submit" id="submit" value="批量下架">
</form>
<script language="javascript">
   
//反选事件
     $("#unSelect").click(function(){
         var checkbox=$(":checkbox");
         for(var i=0;i<checkbox.length;i++){
             checkbox[i].checked=!checkbox[i].checked;
         }
     });
	 
function abc(){
	 if(confirm(' \n您是否确定删除该纪录?')){
		 return true;

	  }else{
		  alert('取消成功！');
		  return false;
	  }
}

</script> 
